<?php
class page_base {

	private $titre;
	private $style=array('skel-noscript', 'style','style-desktop');
	private $corps;
	private $page;
	private $nom;
	private $connect;

	public function __construct($p) {
		$this->page = $p;
		$this->connect=new MyPDO('mysql:host=mysql1.alwaysdata.com;dbname=rdelaporte_ppeusep','90305_robin','squateur');
	}

	protected function GetConnectBD(){
		return $this->connect;
	}



	/******** Gestion des setters  *******************/
	public function __set($propriete, $valeur) {
		switch ($propriete) {
			case 'style' : {
				$this->style[count($this->style)+1] = $valeur;
				break;
			}

			case 'corps' : {
				$this->corps = $valeur;
				break;
			}
			case 'titre' :{
				$this->titre= $valeur;
				break;
			}
		}
	}

	/******** Gestion du titre  *******************/
	private function affiche_titre() {
		echo $this->titre;
	}

	/*************Gestion des styles *********************/
	private function affiche_style() {
		/*foreach ($this->style as $s) {
			echo "<link rel='stylesheet' href='styles/".$s.".css' />\n";
		}*/
		echo'
				<link href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400italic,700,900" rel="stylesheet" />
				<script src="styles/js/jquery.min.js"></script>
				<script src="styles/js/jquery.dropotron.min.js"></script>
				<script src="styles/js/config.js"></script>
				<script src="styles/js/skel.min.js"></script>
				<script src="styles/js/skel-panels.min.js"></script>
				<script src="styles/js/appeldynamique.js"></script>';
	}
	/*************Gestion du header***********/
	private function affiche_header() {
		?>
<header>
	<h1>
		<span>Le module SLAM4 en BTS SIO</span>
	</h1>
	<p class="sous-titre">
		<strong>Toutes les informations :</strong> les cours, TP, corrections
		et autres
	</p>

</header>
<?php
	}
	/*************Gestion du menu*************/
	private function affiche_menu() {




			if(isset($_SESSION['SID']))
			{
				$requete= new PreparationREQ($this->connect);
				$menu = $requete->SelectMenu('menu_registered');
				echo $menu->menu;
			}
			else
			{
				$requete= new PreparationREQ($this->connect);
				$menu = $requete->SelectMenu('menu_unregistered');
				echo $menu->menu;
			}
				
			//echo $corps->MENU;

			/*
			 <nav id="menu-vertical">
			<ul>
			<li><a href="index.php">Accueil</a></li>
			<li><a href="cours.php?section=cours">Les cours</a></li>
			<li><a href="cours.php?section=TP">Les TP</a></li>

			<li id="onhover"><a>Inscription au cross</a>
			<ul class="sous-menu">
			<li><a  href="FormulaireInscription.php?var=Y">Ecole membre USEP</a></li>
			<li><a  href="FormulaireInscription.php?var=N">Ecole non membre USEP</a></li>
			</ul>
			</li>
			</ul>
			</nav>
			*/






		?>


<?php
	}
	/*************Affiche corps***************/
	private function affiche_corps() {
		echo $this->corps;
	}
	private function affiche_formcon(){
	?>
<div id="pop-upconnect">
	<form action="index.php" method="post">
		<input type="text" name="name" placeholder="Identifiant"> <input type="password" name="password" placeholder="Mot de passe"><input
			type="submit" class="button button-style1" value="Connexion">
	</form>
	<form action="FormulaireInscription.php?var=I" method="post">
		<input type="submit" class="button button-style1" value="Inscription">
	</form>
	</div>
<?php
	}

	public function creasession(){
		$nom = $_POST['name'];
		$_SESSION[$nom];
	}
	/************** Affichage du pied de la page ***************************/
	private function affiche_footer() {
		?>
<footer>
	<p>Site de travail Slam4 2014-2015 - servant de base à l'apprentissage
		du PHP</p>
	<p id="copyright">
		Mise en page CA / PFR &copy; 2014 <a
			href="http://chevrollier.e-lyco.fr/">Chevrollier</a>
	</p>
</footer>
<?php
	}
	/**************Cours ou TP*************/
	/*public function retourneget($get){
		if (isset($_GET[$get])){
			$nom = $_GET[$get];
			return $nom;

		}
	}
*/
	/******************** Fonction permettant l'affichage de la page **************/
	public function affiche() {
session_start();
?>


<!-- DOCCTYPE html -->
<html lang='fr'>

<head>
<title><?php if($this->page =='TP'){
	$this->titre="Les TP";
}
$this->affiche_titre(); ?></title>
<meta charset="utf-8" />
<?php 
$this->affiche_style();
?>
</head>
<body class="homepage"> <!-- Header Wrapper -->
<?php $this->affiche_formcon();?>
<div id="header-wrapper" class="wrapper">
	<div class="container">
		<div class="row">
			<div class="12u">

				<!-- Header -->
				<div id="header">

					<!-- Logo -->
					<div id="logo">
						<?php $this->affiche_header();
						?>
					</div>
					<!-- /Logo -->

					<!-- Nav -->
					<?php $this->affiche_menu()?>
					<!-- /Nav -->

				</div>
				<!-- /Header -->

			</div>
		</div>
	</div>
</div>
<!-- /Header Wrapper --> <!-- Main Wrapper -->
<div class="wrapper wrapper-style2">
	<div class="title"></div>
	<div class="container">
		<div class="row">
			<div class="12u">

				<!-- Main -->
				<div id="main">

					<!-- Image 
										<a href="http://fav.me/d5pjw3g" class="image image-featured">
											<img src="images/pic01.jpg" alt="" />
										</a>
									 /Image -->

					<!-- Features -->
					<section id="features">
						<header class="style1">
							<h2>Intro</h2>
							<p class="byline">CACA</p>
						</header>
						<?php 
						$this->affiche_corps();

						?>
						<ul class="actions actions-centered">
							<li><a href="#" class="button button-style1 button-big">Get
									Started</a></li>
							<li><a href="#" class="button button-style2 button-big">More Info</a>
							</li>
						</ul>
					</section>
					<!-- /Features -->

				</div>
				<!-- /Main -->

			</div>
		</div>
	</div>
</div>
<!-- /Main Wrapper --> <?php $this->affiche_footer(); ?>
</div>
</body>

</html>
<?php
	}

}
?>
